home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / tech_art / fnttypes.txt next >
Encoding:
Text File  |  1993-05-11  |  7.3 KB  |  50 lines

  1. The Types of Fonts
  2.  
  3. Windows supports two broad categories of fonts, called "GDI fonts" and "device fonts."
  4. The GDI fonts are stored in files on your hard disk; those that come with Windows are stored in the SYSTEM subdirectory of your Windows directory.
  5. Many of these GDI font files, which are sometimes called "font resource files," have the extension .FON. Each file contains one or more complete fonts. These files are in the New Executable format, which you can verify by running Microsoft's EXEHDR or Borland's TDUMP on them. They are library modules, although somewhat unusual ones in that they contain no code or data. All they contain are two types of resources: a font directory and the fonts themselves.
  6.  
  7. TrueType fonts are also GDI fonts. They are stored in files with the extension .TTF. These files are not in the New Executable format. However, for each .TTF file there is a small .FOT file, which is a resource-only New Executable file that contains a font directory that references the corresponding .TTF file.
  8. The second broad category of fonts, the device fonts, are internal to particular graphics output devices. For video display adapters, device fonts are currently rare. Windows uses the video adapter in graphics mode, so it must use the GDI fonts and write the pixels directly to the video display.
  9.  
  10. For printers, however, device fonts are very common. For instance, Windows can write text to a dot-matrix printer using either the printer's normal text mode or the printer's graphics mode. In text mode, Windows uses a device font and needs to send only the ASCII numbers of the characters out to the printer. In graphics mode, Windows can use a GDI font and must send the pixel patterns to the printer. For laser printers, device fonts can be stored in ROM within the printer or in ROM cartridges. If the printer requires a downloadable font that originates from a disk file, this font is also classified as a device font because it is specific to the particular device.
  11.  
  12. GDI fonts come in three flavorsùraster fonts, stroke fonts, and TrueType fonts.
  13. A raster font is sometimes called a bitmap font, because in a raster font file, each character is stored as a bitmap pixel pattern. Figure 14-1 shows a character from a GDI raster font, enlarged so that you can see the individual pixels.
  14.  
  15.  
  16.  
  17. Each raster font is designed for a specific aspect ratio and character size. Windows can create larger character sizes from GDI raster fonts by simply duplicating rows or columns of pixels. However, this can be done only in integral multiples and within certain limits. Right away, you can probably perceive one major difference between drawing other graphics on the display and writing text to the display using the GDI raster fonts. Although you can draw a rectangle of virtually any size, GDI raster fonts are available only in discrete sizes. (You can't write text using a raster font smaller than the smallest raster font. If you want a GDI raster font of a specific size, that size may not be available.) For this reason, GDI raster fonts are termed "nonscalable" fonts. They cannot be expanded or compressed to an arbitrary size. The primary advantages of raster fonts are performance (because they are very fast to display) and readability (because they have been hand-designed to be as legible as possible).
  18.  
  19. Prior to Windows 3.1, the only other GDI fonts supplied with  Windows were the GDI stroke fonts. The stroke fonts are defined as a series of line segments in a "connect-the-dots" format. Stroke fonts are continuously scalable, which means that the same font can be used for graphics output devices of any resolution, and the fonts can be increased or decreased to any size. However, performance is poor, legibility suffers greatly at small sizes, and at large sizes the characters look decidedly weak because their strokes are single lines. Figure 14-2 shows a character from a blown-up GDI stroke font.
  20.  
  21.  
  22.  
  23. Stroke fonts are now sometimes called "plotter fonts" because they are particularly suitable for plotters but not for anything else.
  24. For both GDI raster fonts and GDI stroke fonts, Windows can "synthesize" boldface, italics, underlining, and strikethroughs without storing separate fonts for each attribute. For italics, for instance, Windows simply shifts the upper part of the character to the right.
  25. With Windows 3.1, modern outline font technology comes to Windows in the form of TrueType. A TrueType font uses straight lines and curves to define the outline of each character. These lines and curves are stored based on an arbitrary coordinate system. By simply scaling these coordinates, TrueType fonts can be continuously scaled and even rotated.
  26.  
  27. When your program wants to use a TrueType font of a particular size, Windows "rasterizes" the font. This means that Windows scales the coordinates connecting the lines and curves of each character using "hints" that are included in the TrueType font file.
  28. These hints compensate for rounding errors that would otherwise cause a resultant character to be unsightly. (For example, in some fonts the two legs of a capital H should be the same width. A blind scaling of the font could result in one leg being a pixel wider than the other. The hints prevent this from happening.) The resultant outline of each character is then used to create a bitmap of the character. These bitmaps are cached in memory for future use.
  29.  
  30. Obviously, the rasterization of a TrueType font takes some time. However, once a TrueType font of a particular size has been rasterized and cached in memory, performance is as fast as using the GDI raster fonts. 
  31. Although the legibility of TrueType fonts is very good, they are not quite as readable as the hand-tuned raster fonts. However, italic and boldface versions of TrueType fonts are not synthesized as they are in the GDI raster fonts and GDI stroke fonts. Instead, separate TrueType font files provide italic and boldface versions. This is preferable because the italic versions of some fonts are quite different from the nonitalic versions. 
  32.  
  33. The following table summarizes the characteristics of the GDI raster, TrueType, and stroke fonts:
  34.  
  35. GDI Font    Performance    Appearance    Scalable
  36.  
  37.  
  38. Raster    The best    The best    Hardly
  39. TrueType    Almost as good as raster    Almost as good as raster    Yes
  40. Stroke    Poor    Poor    Yes
  41. The GDI stroke fonts should be avoided except for use on plotters. For all but the most rudimentary applications involving fonts, the scalability of TrueType fonts greatly outweighs any disadvantages when compared with the GDI raster fonts. Because the TrueType fonts can be used on any type of graphics output device (except plotters), true WYSIWYG is possible. In the past, programs had to approximate printer output by using the GDI raster fonts. Now, TrueType fonts can be used on both devices.
  42.  
  43. Because device fonts are stored in printers and used in a device-specific manner, it is impossible to discuss them in the same detail as GDI fonts. Many modern laser printers (in particular, PostScript printers) support their own outline font technologies. Sometimes the device can italicize or boldface a device font, and sometimes it can't. You can obtain such information from the GetDeviceCaps function using the TEXTCAPS index. If you want to obtain this information for particular printers, you can use the GetDeviceCaps function as shown in the DEVCAPS1 program in Chapter 11.
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. MS Developer Network CD